home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / graph / planar_map.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.8 KB  |  111 lines

  1. #include <LEDA/planar_map.h>
  2. #include <LEDA/graph_alg.h>
  3.  
  4.  
  5.  
  6. main()
  7.  
  8. {  GRAPH<int,int> G;
  9.    node v;
  10.    edge e;
  11.  
  12.    test_graph(G);
  13.  
  14.    edge_array<edge> rev(G);
  15.    Is_Bidirected(G,rev);
  16.  
  17.    list<edge> L;
  18.    forall_edges(e,G) if (rev[e] == nil) L.append(e);
  19.  
  20.    forall(e,L) G.new_edge(target(e),source(e));
  21.  
  22.    if (!PLANAR(G))
  23.    { cerr << "G is not planar!\n";
  24.      exit(1);
  25.     }
  26.  
  27.    int count = 0;
  28.    forall_nodes(v,G) G[v] = count++;
  29.    count = 0;
  30.    forall_edges(e,G) G[e] = count++;
  31.  
  32.    G.print("G = ");
  33.  
  34.    PLANAR_MAP<int,int>  M(G);
  35.  
  36.    M.print();
  37.  
  38.  
  39.    face f;
  40.  
  41.    count = 0;
  42.  
  43.    list<face> FL = M.all_faces();
  44.    forall(f,FL) 
  45.    { cout << string("F%d (%d): ",count++,M.inf(f));
  46.      list<node> L1 = M.adj_nodes(f);
  47.      forall(v,L1) M.print_node(v);
  48.      newline;
  49.      newline;
  50.     }
  51.  
  52. /*
  53.    M.triangulate();
  54.  
  55.  
  56.    count = 0;
  57.    FL= M.all_faces();
  58.    forall(f,FL) 
  59.    { cout << string("F%d (%d): ",count++,M.inf(f));
  60.      list<node> L1 = M.adj_nodes(f);
  61.      forall(v,L1) M.print_node(v);
  62.      newline;
  63.      newline;
  64.     }
  65. */
  66.  
  67. while( Yes("split faces ? ") )
  68. {
  69.    FL= M.all_faces();
  70.    count = 0;
  71.    forall(f,FL)  M.new_node(f,--count);
  72.  
  73.    count = 0;
  74.    FL= M.all_faces();
  75.    forall(f,FL) 
  76.    { cout << string("F%d (%d): ",count++,M.inf(f));
  77.      list<node> L1 = M.adj_nodes(f);
  78.      forall(v,L1) M.print_node(v);
  79.      newline;
  80.      newline;
  81.     }
  82. }
  83.  
  84.  
  85.    list<edge> E;
  86.    edge_array<bool> marked(M,false);
  87.  
  88.    forall_edges(e,M)
  89.     if (!marked[e])
  90.     { E.append(e);
  91.       marked[M.reverse(e)] = true;
  92.      } 
  93.  
  94.  
  95.    forall(e,E)
  96.    { Yes("del_edge ");
  97.      M.del_edge(e);
  98.      count = 0;
  99.      FL= M.all_faces();
  100.      forall(f,FL) 
  101.      { cout << string("F%d (%d): ",count++,M.inf(f));
  102.        list<node> L1 = M.adj_nodes(f);
  103.        forall(v,L1) M.print_node(v);
  104.        newline;
  105.        newline;
  106.       }
  107.  
  108.   }
  109.  
  110. }
  111.